<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            var change = function (amount, coins) {
                //物品 coins
                let bagSize = amount
                let dp = new Array(bagSize + 1).fill(0)
                dp[0] = 1
                for (let i = 0; i < coins.length; i++) {
                    for (let j = coins[i]; j <= bagSize; j++) {
                        dp[j] += dp[j - coins[i]]
                    }
                }
                console.log(dp)
            }
            change(2, [3])
            /* 
            dp[2]+=dp[2-2]  dp[2]=1
            dp[3]+=dp[3-2] dp[3]=dp[1]=0
           
            */
        </script>
    </body>
</html>
